#include <stdio.h>
// 字符串处理
#include <string.h>
//
// Created by 24994 on 2021/9/30.
//

// 管理员登录
int adminLogin()
{
    int flag = 0;
    extern int adminLoginNum;
    extern char dbAdminName[]; // 外部变量
    extern char dbAdminPassword[]; // 外部变量
    char adminName[30];
    char adminPassword[30];
    for (int i = 0; i < adminLoginNum; ++i) {
        printf("please input admin account\n");
        scanf("%s",adminName);
        printf("please input admin password\n");
        scanf("%s",adminPassword);
        if(!strcmp(dbAdminName,adminName) && !strcmp(dbAdminPassword,adminPassword)){
            // 登录成功
            printf("login success\n");
            flag = 1;
            break;
        } else{
            flag = 0;
            printf("login fail, you can login %d time\n",adminLoginNum-i-1);
        }
    }
    return flag;
}
